import { View, Text } from 'react-native'
import React, { Component } from 'react'
import { connect } from 'react-redux';
import Global from '../../global';
import { FlatList } from 'react-native-gesture-handler';

class MyPage extends Component {
    constructor(props) {
        super(props)
        this.state = {
            dataList: []
        }
    }
    async componentDidMount() {
        let result = await this.props.getData()
        this.setState({
            dataList: result.payload.dataList
        })
    }
    render() {
        const { dataList = {} } = this.state;
        return (
            <View style={{padding:10}}> 
                <FlatList
                    data={dataList}
                    renderItem={({ item }) => {
                        return <Text>{item}</Text>
                    }}
                />
            </View>
        )
    }
}
export default connect(
    ({ loading, global, users }) => ({
        loading: loading.effects.users,
        token: global.token,
    }),
    ({ users }) => ({
        getData: users.getData,
    }),
)(MyPage)